package com.spring.boot;

import com.spring.boot.event.TestEvent;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 *
 * @author zhengzihong
 * @date 2018/2/23
 */
@RestController
public class HelloController {

    @Resource
    private ApplicationContext applicationContext;

    @RequestMapping(value = "hello", method = RequestMethod.GET)
    public String hello() {
        applicationContext.publishEvent(new TestEvent(this,"hello"));
        return "hello spring boot2!";
    }
}
